package com.fwpsl.springframework;

import org.springframework.core.metrics.ApplicationStartup;
import org.springframework.core.metrics.StartupStep;

import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

/**
 * @author: 风戏fw
 * @date: 2024/6/6
 * @description:
 */
public class ApplicationStartupDemo {
    private static final Logger LOGGER = Logger.getLogger(ApplicationStartupDemo.class.getSimpleName());

    public static void main(String[] args) throws InterruptedException {
        ApplicationStartup startup = new YootkApplicationStartup();
        StartupStep step = startup.start("yootk.application.start"); // 创建启动的步骤
        for (int x = 0; x < 3; x++) { // 循环记录
            step.tag("yootk.start.step." + x, "服务启动逻辑 - " + x);
            TimeUnit.SECONDS.sleep(1);
        }
        step.end(); // 结束当前的处理步骤
        LOGGER.info("YootkApplication启动标签：");
        for (StartupStep.Tag tag : step.getTags()) {
            LOGGER.info(String.format("【启动阶段】{%s} = {%s}", tag.getKey(), tag.getValue()));
        }
    }
}
